package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.Skull;
import com.ruoyi.web.service.ISkullService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/database/skull")
public class SkullController extends BaseController {
    @Autowired
    private ISkullService skullService;

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('database:skull:query')")
    @GetMapping(value = "/{skullid}")
    public AjaxResult getInfo(@PathVariable("skullid") Long skullid)
    {
        return success(skullService.selectSkullBySkullid(skullid));
    }

    /**
     * 查询【经办人】列表
     */
    @PreAuthorize("@ss.hasPermi('database:skull:list')")
    @GetMapping("/list")
    public TableDataInfo list(Skull skull)
    {
        startPage();
        List<Skull> list = skullService.selectSkullList(skull);
        return getDataTable(list);
    }

    /**
     * 新增【经办人】
     */
    @PreAuthorize("@ss.hasPermi('database:skull:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Skull skull)
    {
        return toAjax(skullService.insertSkull(skull));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('database:skull:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Skull skull)
    {
        return toAjax(skullService.updateSkull(skull));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('database:skull:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{skullids}")
    public AjaxResult remove(@PathVariable Long[] skullids)
    {
        return toAjax(skullService.deleteSkullBySkullids(skullids));
    }

}
